package sm.dbdict.def;

import java.util.ArrayList;
import java.util.List;

public class SqlTables implements Cloneable {
	private String sql_db_type;

	private String sql_table_name;

	private String sql_table_alias;

	private List<SqlLookupTableKeys> sql_lookup_table_keys;

	private List<String> sql_table_options;

	public String getSql_db_type() {
		return sql_db_type;
	}

	public void setSql_db_type(String sql_db_type) {
		this.sql_db_type = sql_db_type;
	}

	public String getSql_table_name() {
		return sql_table_name;
	}

	public void setSql_table_name(String sql_table_name) {
		this.sql_table_name = sql_table_name;
	}

	public String getSql_table_alias() {
		return sql_table_alias;
	}

	public void setSql_table_alias(String sql_table_alias) {
		this.sql_table_alias = sql_table_alias;
	}

	public List<SqlLookupTableKeys> getSql_lookup_table_keys() {
		return sql_lookup_table_keys;
	}

	public void setSql_lookup_table_keys(
			List<SqlLookupTableKeys> sql_lookup_table_keys) {
		this.sql_lookup_table_keys = sql_lookup_table_keys;
	}

	public List<String> getSql_table_options() {
		return sql_table_options;
	}

	public void setSql_table_options(List<String> sql_table_options) {
		this.sql_table_options = sql_table_options;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((sql_db_type == null) ? 0 : sql_db_type.hashCode());
		result = prime
				* result
				+ ((sql_lookup_table_keys == null) ? 0 : sql_lookup_table_keys
						.hashCode());
		result = prime * result
				+ ((sql_table_alias == null) ? 0 : sql_table_alias.hashCode());
		result = prime * result
				+ ((sql_table_name == null) ? 0 : sql_table_name.hashCode());
		result = prime
				* result
				+ ((sql_table_options == null) ? 0 : sql_table_options
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SqlTables other = (SqlTables) obj;
		if (sql_db_type == null) {
			if (other.sql_db_type != null)
				return false;
		} else if (!sql_db_type.equals(other.sql_db_type))
			return false;
		if (sql_lookup_table_keys == null) {
			if (other.sql_lookup_table_keys != null)
				return false;
		} else if (!sql_lookup_table_keys.equals(other.sql_lookup_table_keys))
			return false;
		if (sql_table_alias == null) {
			if (other.sql_table_alias != null)
				return false;
		} else if (!sql_table_alias.equals(other.sql_table_alias))
			return false;
		if (sql_table_name == null) {
			if (other.sql_table_name != null)
				return false;
		} else if (!sql_table_name.equals(other.sql_table_name))
			return false;
		if (sql_table_options == null) {
			if (other.sql_table_options != null)
				return false;
		} else if (!sql_table_options.equals(other.sql_table_options))
			return false;
		return true;
	}

	@Override
	public Object clone() {
		try {
			SqlTables clonedObj = (SqlTables) super.clone();
			clonedObj.sql_db_type = sql_db_type;
			if (sql_lookup_table_keys != null) {
				clonedObj.sql_lookup_table_keys = new ArrayList<SqlLookupTableKeys>();
				for (SqlLookupTableKeys key : sql_lookup_table_keys) {
					clonedObj.sql_lookup_table_keys
							.add((SqlLookupTableKeys) key.clone());
				}
			}
			clonedObj.sql_table_alias = sql_table_alias;
			clonedObj.sql_table_name = sql_table_name;
			if (sql_table_options != null) {
				clonedObj.sql_table_options = new ArrayList<String>();
				for (String option : sql_table_options) {
					sql_table_options.add(option);
				}
			}

			return clonedObj;
		} catch (CloneNotSupportedException e) {
			// this shouldn't happen, since we are Cloneable
			throw new InternalError();
		}
	}
}
